package com.liruo.learn.spring.mvc.controller.valid;

import com.liruo.learn.spring.mvc.controller.valid.custom.CustomValid;
import com.liruo.learn.spring.mvc.controller.valid.custom.CustomValidBean;
import com.liruo.learn.spring.mvc.controller.valid.custom.Group;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import javax.validation.groups.ConvertGroup;

/**
 * @Author:liruo
 * @Date:2023-06-07-22:27:01
 * @Desc
 */
@RestController
@RequestMapping("/valid/custom")
public class CustomValidController {
    @GetMapping("/regx")
    @Valid
    public Boolean regx(@CustomValid CustomValidBean customValidBean){
        return true;
    }

    @GetMapping("/regx/create")
    @Valid
    @ConvertGroup(to = Group.Create.class)
    public Boolean regxCreate(@Valid CustomValidBean customValidBean){
        return true;
    }

    @GetMapping("/regx/update")
    @Valid
    @ConvertGroup(to = Group.Update.class)
    public Boolean regxUpdate(@Valid CustomValidBean customValidBean){
        return true;
    }
}
